package com.jd.finance.core.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jd.finance.core.mapper.OrganizationMapper;
import com.jd.finance.core.pojo.entity.Organization;
import com.jd.finance.core.service.OrganizationService;
import com.jd.finance.result.BaseResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiQingBo
 * @since 2022-05-31
 */
@Service
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements OrganizationService {

    @Resource
    private OrganizationMapper organizationMapper;
    /**
     * 查询所有部门信息
     * @param uid HRid
     * @return
     */
    @Override
    public BaseResult getAllDepartment(Integer uid) {
        if (uid==null) {
            log.error("该用户非HR身份!");
            return BaseResult.error().message("该用户非HR身份!");
        }
        List<Organization> list=organizationMapper.selectList(null);
        if (list==null || list.size()==0) {
            log.error("未查询到部门信息!");
            return BaseResult.error().message("未查询到部门信息!");
        }
        return BaseResult.ok().data("organList",list).message("查询成功!");
    }
}
